// components/notice/index.js
var config = require('../../utils/config.js')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    notice: Object,
    index: Number
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    detail() {
        wx.navigateTo({
          url: '../detail/index?id=' + this.data.notice.noticeId,
        })
    },
    del() {
      let token = wx.getStorageSync('token')
      let _this = this;
      wx.request({
        url: config.HOST + '/notice/delComment',
        data: {
          token: token,
          commentId: this.properties.notice.commentId
        },
        success() {
          _this.triggerEvent('delNotice', _this.properties.index)
        }
      })
    },
    // 跳转到公告分类上去
    categoryList(event) {
      let cid = event.target.dataset.cid
      let cname = event.target.dataset.cname
      wx.navigateTo({
        url: '../category/index?cid=' + cid + '&cname=' + cname,
      })
    }
  }
})
